<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%@ taglib prefix="s" uri="/struts-tags"%>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>

	<head>
		<base href="<%=basePath%>">

		<title>开始考试</title>

		<meta http-equiv="pragma" content="no-cache">
		<meta http-equiv="cache-control" content="no-cache">
		<meta http-equiv="expires" content="0">
		<link rel="stylesheet" href="css/font-awesome/css/font-awesome.css" />
		<link rel="stylesheet" href="css/common.css" />
		<link rel="stylesheet" href="css/contenRight.css" />
		<link rel="stylesheet" href="css/responsive.css" />
		<script type="text/javascript" src="js/jquery.min.js"></script>
		<script type="text/javascript" src="js/index.js"></script>
		<script type="text/javascript" src="js/app.js"></script>
		<link rel="stylesheet" href="css/pulg/jquery-ui/jquery-ui.min.css" />
		<script type="text/javascript" src="css/pulg/jquery-ui/jquery-ui.min.js"></script>

		<script type="text/javascript">
			var ksTime; //定义考试时间以分钟计算
			ksTime = 60; //设置时间 这里设置为0.1代表是6秒,测试用
			if(readCookie("ss") == "") {
				setCookie("ss", new Date(), ksTime / 60);
			}

			function sT() {
				var tti = new Date();
				var lt = parseInt((tti - new Date(readCookie("ss"))) / 1000)
				if((ksTime * 60 - lt) < 0) {
					setCookie("ss", new Date(), 0);
					alert("考试时间到!\n即将提交试卷!");
					document.forms[0].submit();
				} else {
					lm = Math.floor(lt / 60);
					ls = lt % 60;
					allY = ksTime * 60 - lt;
					ym = Math.floor(allY / 60);
					ys = allY % 60;
					document.getElementById("tTime").innerHTML = "考试已经开始了" + lm + "分" +
						ls + "秒" + ",剩余" + ym + "分" + ys + "秒";
					var ttt = setTimeout("sT()", 1000);
				}
			}

			function readCookie(name) {
				var cookieValue = "";
				var search = name + "=";
				if(document.cookie.length > 0) {
					offset = document.cookie.indexOf(search);
					if(offset != -1) {
						offset += search.length;
						end = document.cookie.indexOf(";", offset);
						if(end == -1)
							end = document.cookie.length;
						cookieValue = document.cookie.substring(offset, end)
					}
				}
				return cookieValue;
			}

			function setCookie(name, value, hours) {
				var expire = "";
				if(hours != null) {
					expire = new Date((new Date()).getTime() + hours * 3600000);
					expire = "; expires=" + expire.toGMTString();
				}
				document.cookie = name + "=" + value + expire;
			}
		</script>

	</head>

	<body onload="sT()" style="overflow:-Scroll;overflow-x:hidden;">
		<div class="list-page">
			<div class="list-page-content">
				<div class="taskTabs">
					<ul class="taskOptions">
						<li>
							<a class="btnlist tabs selected" href="#overtime0" id="taskList">
								<i class="icon-user"></i> 在线考试
							</a>
						</li>

					</ul>
					<div class="clear"></div>
					<div id="overtime0" class="task" data-pattern="priority-cloumns" style="display: none;">
						<div class="editPage">
							<div class="editPages">
								<div class="editPageTitle">
									<p class="titleLeft">
										<i class="icon-list-alt"></i>
										<span>在线考试</span>
									</p>
									<div class="clear"></div>
								</div>

								<div class="editPageInfo" style="display: block;">
									<form class="form-horizontal editForm" id="submitForm" action="submitExam" method="post">
										<table width="100%" height="100%" border="0" align="center" cellpadding="0" cellspacing="10">
											<tr>
												<td>
													<div align="center">
														考试时间：${time } 分钟
													</div>
												</td>
												<td>
													<div align="center">
														考生：${studentInfo.studentName}
													</div>
												</td>
												<td>
													<div align="center">
														总分 ：${score } 分
													</div>
												</td>
											</tr>
											<tr>
												<td>
													&nbsp;
												</td>
												<td>
													<div id="tTime"></div>
												</td>
												<td>
													&nbsp;
												</td>
											</tr>
											<tr>
												<td colspan="3" bgcolor="#999999">
													选择题(每小题5分，共20个)
												</td>
											</tr>
											<!--题目开始-->

											<s:iterator value="#request.subjects" var="subject" status="sta">
												<tr>
													<input type="hidden" name="subjectID" value="${subject.subjectID}" />
													<td colspan="3">
														<strong>第${sta.index + 1}题&nbsp;${subject.subjectTitle}</strong>
													</td>
												</tr>
												<tr>
													<td colspan="3">
														<strong>A．</strong>${subject.subjectOptionA}
													</td>
												</tr>
												<tr>
													<td colspan="3">
														<strong>B．</strong>${subject.subjectOptionB}
													</td>
												</tr>
												<tr>
													<td colspan="3">
														<strong>C．</strong>${subject.subjectOptionC}
													</td>
												</tr>
												<tr>
													<td colspan="3">
														<strong>D．</strong>${subject.subjectOptionD}
													</td>
												</tr>
												<tr>
													<td height="32" colspan="3" bgcolor="#CCCCCC">
														选择答案：
														<input type="radio" name="subjectAnswer${sta.index}" value="A" checked="checked" /> A
														<input type="radio" name="subjectAnswer${sta.index}" value="B" /> B
														<input type="radio" name="subjectAnswer${sta.index}" value="C" /> C
														<input type="radio" name="subjectAnswer${sta.index}" value="D" /> D
													</td>
												</tr>
											</s:iterator>
											<!--题目结束-->
											<tr>
												<td colspan="3">
													<div align="center">
														<input type="submit" value=" 提交答卷 " name="submit" />
													</div>
												</td>
											</tr>
										</table>
									</form>

								</div>
							</div>
						</div>
					</div>

				</div>

			</div>
		</div>
	</body>

</html>